<!DOCTYPE html>
<html lang="pt-br">
<head>
    <!-- Codificação de caracteres -->
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    <!--[if lt IE 9]>
    <script type="text/javascript">
        document.createElement("nav");
        document.createElement("header");
        document.createElement("footer");
        document.createElement("section");
        document.createElement("aside");
        document.createElement("article");
    </script>
    <![endif]-->
    
    <title>{% if titulo %}{{ titulo }} - {% endif %}{{ dados }}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">


    <!-- Style sheets -->
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/bootstrap.min.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/bootstrap-theme.min.css" />
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/smoothness/jquery-ui.custom.min.css" />
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/estilo.css" media="screen" />
    
    {% if css %}
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/{{ css }}.css" />
    {% endif %}
    
    {% block template_css %}{% endblock %}
</head>
<body>

<nav class="navbar navbar-default" role="navigation">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" title="Início" href="/"><em>CtrlSYS Restaurante</em></a>
    </div>
    
    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
        <ul class="nav navbar-nav">
            {% if user.is_authenticated %}
            <li><a href="/" title="Início"><span class="glyphicon glyphicon-home"></span> Home</a></li>
            <li class="dropdown" style="display: none;">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">Mesa <b class="caret"></b></a>
                <ul class="dropdown-menu">
                    <li><a href="#">Salão</a></li>
                    <li><a href="#">Balcão</a></li>
                    <li><a href="#">Entrega</a></li>
                </ul>
            </li>
            
            <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-cog"></span> Opções <b class="caret"></b></a>
                    <ul class="dropdown-menu">
                      {% if perms.restaurante.view_report %}
                      <li><a href="/relatorio">Relatório</a></li>
                      {% endif %}
                      {% if perms.restaurante.view_produtos %}
                      <li><a href="/admin/estoque/produto">Produtos</a></li>
                      {% endif %}
                      <li><a href="/estoque/avisos/">Avisos</a></li>
                      {% if perms.registro.can_change %}
                      <li><a href="/admin/registro/evento/">Eventos</a></li>
                      {% endif %}
                      <li class="divider"></li>
                      {% if user.is_staff %}
                      <li><a href="/admin/">Administração</a></li>
                      {% endif %}
                      <li class="divider"></li>
                      {% if perms.restaurante.ver_pagamento %}
                      <li><a href="/pagamentos/receber/">Pagamentos a receber</a></li>
                      <li><a href="/pagamentos/retiradas/">Entrada/Saída</a></li>
                      {% endif %}
                      {% if perms.restaurante.fechar_caixa %}
                      <li class="{% if not perms.restaurante.fechar_caixa or not pedidos.count == 0 %}disabled{% endif %}"><a href="/fechar_caixa/">Fechar o caixa</a></li>
                      {% endif %}
                    </ul>
            </li>
            {% endif %}
            <!-- <li><a href="/sobre/">Sobre</a></li>  -->
            <li><a href="/contatos/"><span class="glyphicon glyphicon-envelope"></span> Contatos</a></li>
        </ul>
        <form class="navbar-form navbar-left" role="search" style="display: none;">
            <div class="form-group">
                <input type="text" class="form-control" placeholder="Pesquisa">
            </div>
            <button type="submit" class="btn btn-default">Pesquisar</button>
        </form>
        
        {% if user.is_authenticated %}
        <p class="navbar-text pull-right"><em>Logado como <strong>{{ user }}</strong></em>. <a href="/logout/" class="navbar-link">Sair <span class="glyphicon glyphicon-log-out"></span></a></p>
        {% endif %}
    </div><!-- /.navbar-collapse -->
</nav>


<div class="container" id="main_container">
{% autoescape off %}
{% if mensagem %}
<div class="alert alert-block alert-dismissable alert-{{ mensagem_tipo }} {% if mensagem_fixed %}navbar-fixed-{{ mensagem_fixed }}{% endif %} alert-dismissable">
    <button type="button" class="close" data-dismiss="alert">&times;</button>
    {% if mensagem_titulo %}<h4>{{ mensagem_titulo }}</h4>{% endif %}
    <p>{{ mensagem }}</p>
</div>
{% endif %}
{% endautoescape %}

{% block conteudo %}
{% endblock %}
</div>
    
<!-- JavaScript - Script -->
<script type="text/javascript" src="{{ STATIC_URL }}js/jquery.min.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/jquery-ui.custom.min.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/bootstrap.min.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/script.js"></script>

{% if js %}
<script type="text/javascript" src="{{ STATIC_URL }}js/{{ js }}.js"></script>
{% endif %}

<script type="text/javascript">
$(document).ready(function() {
	
	{% if user.is_authenticated %}
	// experimental
	
	$(document).keyup(function(e) {
		if (e.ctrlKey) {
			atalhos = [27, 36];
			if (atalhos.indexOf(e.keyCode) > -1) {
				switch (e.keyCode) {
        			case 8: // Voltar
        				window.location = '{% if prev %}{{ prev }}{% else %}../{% endif%}';
        				break;
        			case 27:
        				if (confirm('Deseja realmente sair?')) {
        					window.location = '/logout/';
        				}
        				break;
        			case 36:
        				window.location = '/';
        				break;
    				default:
    					alert(e.keyCode);
        		}
			}	
		}
	});
	{% endif %}
});
</script>

{% block template_js %}{% endblock %}
</body>
</html>